<html xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:t="http://myfaces.apache.org/tomahawk">

    <f:view>
        <f:loadBundle var="text" basename="#{remissionList.bundleName}"/>
        <head>
            <title>#{text['remissionList.title']}</title>
            <meta name="heading" content="#{text['remissionList.heading']}"/>
            <meta name="menu" content="OperationMenu"/>
        </head>
        <body id="remissionList">
            <h:form id="editremission">

                <h:commandButton value="#{text['button.search']}" action="#{remissionList.execute}" id="search" styleClass="button"/>
                <h:commandButton value="#{text['button.done']}" action="mainMenu" id="cancel" immediate="true" styleClass="button" style="margin-left: 5px"/>                

                <h:outputText></h:outputText>
                <h:panelGroup>
                    <table>
                        <tr>
                            <td>
                                <t:htmlTag value="div">
                                    <h:outputLabel styleClass="desc" for="id" value="#{text['remission.id']}"/>
                                    <h:inputText styleClass="text medium" id="id" value="#{remissionList.id}"/>
                                    <t:message for="id" styleClass="fieldError"/>
                                </t:htmlTag>
                            </td>
                            <td>
                                <t:htmlTag value="div">
                                    <h:outputLabel styleClass="desc" for="quotationId" value="#{text['remission.quotation']}"/>
                                    <h:inputText styleClass="text medium" id="quotationId" value="#{remissionList.quotationId}"/>
                                    <t:message for="quotationId" styleClass="fieldError"/>
                                </t:htmlTag>
                            </td>
                            <td>
                                <t:htmlTag value="div">
                                    <h:outputLabel styleClass="desc" for="description" value="#{text['remission.description']}"/>
                                    <h:inputText styleClass="text medium" id="description" value="#{remissionList.description}"/>
                                    <t:message for="description" styleClass="fieldError"/>
                                </t:htmlTag>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <t:htmlTag value="div">
                                    <h:outputLabel styleClass="desc" for="date" value="#{text['remission.date']}"/>
                                    <t:inputCalendar id="date" value="#{remissionList.date}" renderAsPopup="true"
                                                     popupDateFormat="dd/MM/yyyy" popupTodayString="Hoy es "
                                                     popupWeekString="Semana" lang="es">
                                    </t:inputCalendar>
                                    <t:message for="date" styleClass="fieldError"/>
                                </t:htmlTag>
                            </td>
                            <td>
                                <t:htmlTag value="div">
                                    <h:outputLabel styleClass="desc" for="company" value="#{text['quotation.company']}"/>
                                    <h:selectOneMenu value="#{remissionList.company}" id="company" styleClass="select">
                                        <f:selectItem itemLabel="Todas"/>
                                        <t:selectItems value="#{remissionList.companies}" var="company" itemLabel="#{company.description}" itemValue="#{company}"/>
                                        <f:converter converterId="objconverter"/>
                                    </h:selectOneMenu>
                                    <t:message for="company" styleClass="fieldError"/>
                                </t:htmlTag>
                            </td>                            
                        </tr>
                    </table>
                </h:panelGroup>
                <h:outputText></h:outputText>

                <!-- Error from this table is caused by http://issues.apache.org/jira/browse/TOMAHAWK-466 -->
                <t:dataTable id="remissions" var="remission" style="margin-top: 10px"
                             value="#{remissionList.remissions}" rows="25" sortColumn="#{remissionList.sortColumn}"
                             sortAscending="#{remissionList.ascending}" styleClass="scrollerTable table"
                             headerClass="standardTable_Header" rowClasses="standardTable_Row1,standardTable_Row2"
                             columnClasses="standardTable_Column,standardTable_Column,standardTable_Column,standardTable_Column,standardTable_ColumnCentered">
                    <t:column width="5%">
                        <f:facet name="header">
                            <t:commandSortHeader columnName="id" arrow="true">
                                <h:outputText value="#{text['remission.id']}" />
                            </t:commandSortHeader>
                        </f:facet>
                        <h:commandLink action="#{remissionForm.edit}" value="#{remission.id}">
                            <f:param name="id" value="#{remission.id}"/>
                            <f:param name="from" value="list"/>
                        </h:commandLink>
                    </t:column>
                    <t:column width="30%">
                        <f:facet name="header">
                            <t:commandSortHeader columnName="description" arrow="true">
                                <h:outputText value="#{text['remission.description']}" />
                            </t:commandSortHeader>
                        </f:facet>
                        <h:outputText value="#{remission.description}" escape="true"/>
                    </t:column>
                    <t:column width="10%">
                        <f:facet name="header">
                            <t:commandSortHeader columnName="date" arrow="true">
                                <h:outputText value="#{text['remission.date']}"/>
                            </t:commandSortHeader>
                        </f:facet>
                        <h:outputText value="#{remission.date}" escape="true">
                            <f:convertDateTime pattern="dd/MM/yyyy"/>
                        </h:outputText>
                    </t:column>
                    <t:column width="10%">
                        <f:facet name="header">
                            <t:commandSortHeader columnName="workOrder" arrow="true">
                                <h:outputText value="#{text['remission.workOrder']}"/>
                            </t:commandSortHeader>
                        </f:facet>
                        <h:outputText value="#{remission.workOrder.id}" escape="true"/>
                    </t:column>
                    <t:column width="10%">
                        <f:facet name="header">
                            <h:outputText value="#{text['remission.quotation']}"/>
                        </f:facet>
                        <h:outputText value="#{remission.workOrder.quotation.id}" escape="true"/>
                    </t:column>
                    <t:column width="10%">
                        <f:facet name="header">
                            <h:outputText value="#{text['quotation.company']}"/>
                        </f:facet>
                        <h:outputText value="#{remission.workOrder.quotation.contact.company.description}" escape="true"/>
                    </t:column>

                    <t:column width="10%">
                        <f:facet name="header">
                            <t:commandSortHeader columnName="contact" arrow="true">
                                <h:outputText value="#{text['quotation.contact']}"/>
                            </t:commandSortHeader>
                        </f:facet>
                        <h:outputText value="#{remission.workOrder.quotation.contact.firstName}" escape="true"/>
                        <h:outputText value=" #{remission.workOrder.quotation.contact.lastName}" escape="true"/>
                    </t:column>
                </t:dataTable>

                <t:saveState id="save1" value="#{remissionList.remissions}"/>

                <ui:include src="/common/tableFooter.xhtml">
                    <ui:param name="tableName" value="remissions"/>
                </ui:include>

                <script type="text/javascript">
                    highlightTableRows("editremission:remissions");
                </script>

            </h:form>
        </body>
    </f:view>
</html>